package cn.btks.resultintegration.rule.controller;

import cn.btks.commonserver.result.ResultState;
import cn.btks.commonserver.result.StateInfo;
import cn.btks.resultintegration.rule.pojo.IndustrialStructureSecondCategory;
import cn.btks.resultintegration.rule.service.IndustrialStructureSecondCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author lijun
 * @Date 2021/2/19 11:05
 */
@RestController
@RequestMapping("api/v1.0/resultIntegration/rule")
@Api(tags = "规则模块")
@Validated
public class IndustrialStructureSecondCategoryController {

    @Autowired
    IndustrialStructureSecondCategoryService industrialStructureSecondCategoryService;

    @GetMapping("/industrialTechnology/findAllIndustrialTechnology")
    @ApiOperation("查询所有产业结构调整指导目录的小类")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findAllIndustrialTechnology() {
        List<IndustrialStructureSecondCategory> industrialStructureSecondCategoryList = industrialStructureSecondCategoryService.findAllIndustrialStructureSecondCategory();
        return industrialStructureSecondCategoryList != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), industrialStructureSecondCategoryList) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }

    @GetMapping("/industrialTechnology/findAllByCategoryId/{categoryId}")
    @ApiOperation("根据产业结构调整目录大类ID查询其下小类")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "categoryId", value = "产业结构调整目录类别ID", required = true, dataType = "long"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findAllByCategoryId(@PathVariable("categoryId") Long categoryId) {
        List<IndustrialStructureSecondCategory> industrialStructureSecondCategoryList = industrialStructureSecondCategoryService.findAllByCategoryId(categoryId);
        return industrialStructureSecondCategoryList != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), industrialStructureSecondCategoryList) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }
}
